package com.fastCms.manager.frame.controller;


import com.fastCms.business.frame.busi.CloudMenuManageService;
import com.fastCms.business.frame.pojo.po.MenuOfUserPO;
import com.fastCms.business.frame.pojo.po.MenuPointOfUserPO;
import com.fastCms.business.frame.pojo.vo.CloudMenuVO;
import com.fastCms.business.frame.response.ApiResponse;
import com.fastCms.business.frame.response.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 哈密瓜科技 版权所有 © Copyright 2019<br>
 *
 * @Description: 菜单管理中心<br>
 * @Project: healthyPro <br>0
 * @CreateDate: Created in 2019/3/7 下午3:48 <br>
 * @Author: <a href="lsquan666@163.com">lsquan</a>
 */
@RestController
@RequestMapping("/cloudMenu")
@Api(value = "CloudMenuController", tags = "后端-菜单管理中心")
public class CloudMenuController {

    @Autowired
    private CloudMenuManageService cloudMenuManageServiceImpl;

    @PostMapping("/findMenuByUser")
    @ApiOperation(value = "查询当前用户的菜单", notes = "")
    public ApiResponse<List<CloudMenuVO>> findMenuByUser(@RequestBody MenuOfUserPO param) {
        ApiResponse<List<CloudMenuVO>> result = cloudMenuManageServiceImpl.findMenuByUser(param);
        return result;
    }

    @PostMapping("/findByRoleId/{roleId}")
    @ApiOperation(value = "根据角色ID查询菜单", notes = "展示菜单和菜单下的权限点")
    public ApiResponse<List<CloudMenuVO>> findByRoleId(@PathVariable String roleId) {
        List<CloudMenuVO> cloudMenus = cloudMenuManageServiceImpl.findByRoleId(roleId);
        return ResponseUtil.success(cloudMenus);
    }

    @PostMapping("/findMenuPoint")
    @ApiOperation(value = "查询用户拥有的权限点", notes = "传菜单ID则只查该菜单下的权限点.不传则查所有权限点")
    public ApiResponse<List<CloudMenuVO>> findMenuPoint(@RequestBody MenuPointOfUserPO param) {
        ApiResponse<List<CloudMenuVO>> result = cloudMenuManageServiceImpl.findMenuPoint(param);
        return result;
    }


}

